package com.wn.ziroom.controller;


import com.wn.ziroom.entity.Cities;
import com.wn.ziroom.entity.Provinces;
import com.wn.ziroom.service.CitiesService;
import com.wn.ziroom.service.ProvincesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wangzhijia
 * @since 2023-02-23 02:27:54
 */
@Controller
@RequestMapping("/ziroom_portal/cities")
public class CitiesController {

    private ProvincesService provincesService;
    private CitiesService citiesService;

    @Autowired
    public void setProvincesService(ProvincesService provincesService) {
        this.provincesService = provincesService;
    }

    @Autowired
    public void setCitiesService(CitiesService citiesService) {
        this.citiesService = citiesService;
    }

    @ResponseBody
    @PostMapping("/showCities")
    public List<Cities> showCities(@RequestParam("provinces") String provinces){
        Provinces pro = provincesService.findByProName(provinces);
        List<Cities> citiesList = citiesService.findListByCode(pro.getCode());
        return citiesList;
    }
}

